home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / apps / 42 / apndx2.prf < prev    next >
Text File  |  1986-07-17  |  3KB  |  140 lines

  1. .!****************************************************************************
  2. .! 
  3. .! ANTIC PUBLISHING INC., COPYRIGHT 1985.  REPRINTED BY PERMISSION.
  4. .!
  5. .! ** Professional GEM ** by Tim Oren
  6. .!
  7. .! Proff File by ST enthusiasts at
  8. .! Case Western Reserve University
  9. .! Cleveland, Ohio
  10. .! uucp : decvax!cwruecmp!bammi
  11. .! csnet: bammi@case
  12. .! arpa : bammi%case@csnet-relay
  13. .! compuserve: 71515,155
  14. .!
  15. .!****************************************************************************
  16. .!
  17. .!            Begin Appendix 2
  18. .!
  19. .!***************************************************************************
  20. .!
  21. .!
  22. .AP II Sample Code for Part III
  23. /*
  24. >>>>>>>>>>>>>>>>>>>>>>> Basic Dialog Handler <<<<<<<<<<<<<<<<<<<<<<<
  25. */
  26.  
  27. WORD
  28. hndl_dial(tree, def, x, y, w, h)
  29. LONG    tree;
  30. WORD    def;
  31. WORD    x, y, w, h;
  32. {
  33.     WORD    xdial, ydial, wdial, hdial, exitobj;
  34.  
  35.     form_center(tree, &xdial, &ydial, &wdial, &hdial);
  36.     form_dial(0, x, y, w, h, xdial, ydial, wdial, hdial);
  37.     form_dial(1, x, y, w, h, xdial, ydial, wdial, hdial);
  38.     objc_draw(tree, ROOT, MAX_DEPTH, xdial, ydial, wdial, hdial);
  39.     exitobj = form_do(tree, def) & 0x7FFF;
  40.     form_dial(2, x, y, w, h, xdial, ydial, wdial, hdial);
  41.     form_dial(3, x, y, w, h, xdial, ydial, wdial, hdial);
  42.     return (exitobj);
  43. }
  44. .bp
  45. /*
  46. >>>>>>>>>>>>>>>>>>>>>>> Object rectangle utility <<<<<<<<<<<<<<<<<<<<<<<<<
  47. */
  48.  
  49. VOID
  50. objc_xywh(tree, obj, p)        /* get x,y,w,h for specified object    */
  51. LONG    tree;
  52. WORD    obj;
  53. GRECT    *p;
  54. {
  55.     objc_offset(tree, obj, &p->g_x, &p->g_y);
  56.     p->g_w = LWGET(OB_WIDTH(obj));
  57.     p->g_h = LWGET(OB_HEIGHT(obj));
  58. }
  59. .bp
  60. /*
  61. >>>>>>>>>>>>>>>>>>>>>>> Object flag utilities <<<<<<<<<<<<<<<<<<<<<<<<<<<
  62. */
  63.  
  64. VOID
  65. undo_obj(tree, which, bit)    /* clear specified bit in object state    */
  66. LONG    tree;
  67. WORD    which, bit;
  68. {
  69.     WORD    state;
  70.  
  71.     state = LWGET(OB_STATE(which));
  72.     LWSET(OB_STATE(which), state & ~bit);
  73. }
  74.  
  75. VOID
  76. desel_obj(tree, which)        /* turn off selected bit of spcfd object*/
  77. LONG    tree;
  78. WORD    which;
  79. {
  80.     undo_obj(tree, which, SELECTED);
  81. }
  82.  
  83. VOID
  84. do_obj(tree, which, bit)    /* set specified bit in object state    */
  85. LONG    tree;
  86. WORD    which, bit;
  87. {
  88.     WORD    state;
  89.  
  90.     state = LWGET(OB_STATE(which));
  91.     LWSET(OB_STATE(which), state | bit);
  92. }
  93.  
  94. VOID
  95. sel_obj(tree, which)        /* turn on selected bit of spcfd object    */
  96. LONG    tree;
  97. WORD    which;
  98. {
  99.     do_obj(tree, which, SELECTED);
  100. }
  101.  
  102. BOOLEAN
  103. statep(tree, which, bit)
  104. LONG    tree;
  105. WORD    which;
  106. WORD    bit;
  107. {
  108.     return ( (LWGET(OB_STATE(which)) & bit) != 0);
  109. }
  110.  
  111. BOOLEAN
  112. selectp(tree, which)
  113. LONG    tree;
  114. WORD    which;
  115. {
  116.     return statep(tree, which, SELECTED);
  117. }
  118. .bp
  119. /*
  120. >>>>>>>>>>>>>>>>>>>>>> Sample radio buttons after dialog <<<<<<<<<<<<<<<<<<<<
  121. */
  122.  
  123.  
  124. WORD
  125. encode(tree, ob1st, num)
  126. LONG    tree;
  127. WORD    ob1st, num;
  128. {
  129.     for (; num--; )
  130.         if (selectp(ob1st+num))
  131.             return(num);
  132.     return (-1);
  133. }
  134. .!
  135. .!****************************************************************************
  136. .!
  137. .!            End Appendix 3
  138. .!
  139. .!****************************************************************************
  140.